package com.hncatv.snailantennae;

import com.hncatv.snailantennae.bean.EventBean;
import com.hncatv.snailantennae.bean.IPanelEventBean;

import java.util.Map;



public class IPanelEventTask implements Runnable {


    private String service;
    private String event_time;
    private String userId;
    private String region;
    private String deviceId;
    private String ca;
    private String stb;
    private Map ecp;

    public IPanelEventTask(String service, String event_time, String userId,String region,String deviceId,String ca,String stb,Map ecp) {
        this.service = service;
        this.event_time = event_time;
        this.userId = userId;
        this.ecp = ecp;
        this.region = region;
        this.deviceId = deviceId;
        this.ca = ca;
        this.stb = stb;

    }

    @Override
    public void run() {

        if (!SnailEventManager.hasInit) {
            ELogger.logError(SnailConstant.TAG, "please init SnailEventManager!");
            return;
        }

        if (SnailConstant.SWITCH_OFF) {
            ELogger.logWrite(SnailConstant.TAG, "the sdk is SWITCH_OFF");
            return;
        }

        try {

            IPanelEventBean bean = EventDecorator.generateEventBean(service, event_time,userId,region,deviceId,ca,stb,ecp);

            if (bean == null) {
                ELogger.logWrite(SnailConstant.TAG, " event bean == null");
                return;
            }

            ELogger.logWrite(SnailConstant.TAG, " event " + bean.toString());


            EDBHelper.addEventData(bean);



            EventDecorator.pushEventByNum();


        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
